<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('店铺预订单列表')" />
</head>
<body class="gray-bg">
     <div class="container-div">
        <div class="row">
            <div class="col-sm-12 search-collapse">
                <form id="formId">
                    <div class="select-list">
                        <ul>
                            <li>
                                <label style="width: 120px;">下单店铺名称：</label>
                                <input type="text" name="storeId"/>
                            </li>
                            <li>
                                <label>状态：</label>
                                <select name="orderState" th:with="type=${@dict.getType('agent_order_state')}">
                                    <option value="">所有</option>
                                    <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                                </select>
                            </li>
                            <li>
                                <label>收货人：</label>
                                <input type="text" name="orderName"/>
                            </li>
                            <li>
                                <label>收货电话：</label>
                                <input type="text" name="orderPhone"/>
                            </li>
                            <li>
                                <label>详细地址：</label>
                                <input type="text" name="orderAddress"/>
                            </li>
                            <li>
                                <label>所属大区：</label>
                                <input type="text" name="agentId"/>
                            </li>
                            <li>
                                <label>订单类型：</label>
                                <select name="orderType" th:with="type=${@dict.getType('store_order_type')}">
                                    <option value="">所有</option>
                                    <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                                </select>
                            </li>
                            <li class="select-time">
                                <label>创建时间：</label>
                                <input type="text" class="time-input" id="startTime" placeholder="开始时间" name="params[beginCreateTime]"/>
                                <span>-</span>
                                <input type="text" class="time-input" id="endTime" placeholder="结束时间" name="params[endCreateTime]"/>
                            </li>
                            <li>
                                <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                                <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                            </li>
                        </ul>
                    </div>
                </form>
            </div>

            <!--<div class="btn-group-sm" id="toolbar" role="group">
                <a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="zsyh:storeOrder:add">
                    <i class="fa fa-plus"></i> 添加
                </a>
                <a class="btn btn-primary single disabled" onclick="$.operate.edit()" shiro:hasPermission="zsyh:storeOrder:edit">
                    <i class="fa fa-edit"></i> 修改
                </a>
                <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()" shiro:hasPermission="zsyh:storeOrder:remove">
                    <i class="fa fa-remove"></i> 删除
                </a>
                <a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="zsyh:storeOrder:export">
                    <i class="fa fa-download"></i> 导出
                </a>
            </div>-->
            <div class="col-sm-12 select-table table-bordered">
                <table id="bootstrap-table"></table>
            </div>
        </div>
    </div>
    <th:block th:include="include :: footer" />
    <script th:inline="javascript">
        var editFlag = [[${@permission.hasPermi('zsyh:storeOrder:edit')}]];
        var removeFlag = [[${@permission.hasPermi('zsyh:storeOrder:remove')}]];
        var orderStateDatas = [[${@dict.getType('agent_order_state')}]];
        var orderTypeDatas = [[${@dict.getType('store_order_type')}]];
        var prefix = ctx + "zsyh/storeOrder";

        $(function() {
            var options = {
                url: prefix + "/list",
                createUrl: prefix + "/add",
                updateUrl: prefix + "/edit/{id}",
                removeUrl: prefix + "/remove",
                exportUrl: prefix + "/export",
                showSearch: false,
                showRefresh: false,
                showToggle: false,
                showColumns: false,
                modalName: "店铺预订单",
                columns: [{
                    field : 'Number',
                    title : '序号',
                    align: 'center',
                    width: 20,
                    formatter : function(value, row, index) {
                        var pageSize = $('#bootstrap-table').bootstrapTable('getOptions').pageSize;//通过表的#id 可以得到每页多少条
                        var pageNumber = $('#bootstrap-table').bootstrapTable('getOptions').pageNumber;//通过表的#id 可以得到当前第几页
                        return pageSize * (pageNumber - 1) + index + 1;//返回每条的序号： 每页条数 * （当前页 - 1 ）+ 序号
                    }
                },
                {
                    field: 'id',
                    title: '主键',
                    align: 'center',
                    visible: false
                },
                {
                    field: 'storeName',
                    align: 'center',
                    title: '下单店铺名称'
                },
                {
                    field: 'orderState',
                    align: 'center',
                    title: '状态',
                    formatter: function(value, row, index) {
                       return $.table.selectDictLabel(orderStateDatas, value);
                    }
                },
                {
                    field: 'orderName',
                    align: 'center',
                    title: '收货人'
                },
                {
                    field: 'orderPhone',
                    align: 'center',
                    title: '收货电话'
                },
                {
                    field: 'orderAddress',
                    align: 'center',
                    title: '详细地址'
                },
                /*{
                    field: 'partsStoreId',
                    title: '配件店铺id'
                },*/
                {
                    field: 'agentName',
                    align: 'center',
                    title: '所属大区'
                },
                {
                    field: 'orderType',
                    align: 'center',
                    title: '订单类型',
                    formatter: function(value, row, index) {
                       return $.table.selectDictLabel(orderTypeDatas, value);
                    }
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function(value, row, index) {
                        var actions = [];
                        actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="viewDetail(\'' + row.id + '\')"><i class="fa fa-edit"></i>查看详情</a> ');
                        /*actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.id + '\')"><i class="fa fa-remove"></i>删除</a>');*/
                        return actions.join('');
                    }
                }]
            };
            $.table.init(options);
        });

        function viewDetail(id) {
            layer.open({
                type: 2,
                area: ['1200px', ($(window).height() - 50) + 'px'],
                fix: false,
                //不固定
                maxmin: true,
                shade: 0.3,
                title: "查看详情",
                content: prefix + "/edit/"+id,
                btnClose: 1,
                // 弹层外区域关闭
                shadeClose: true,
                yes: function(index, layero) {
                    var iframeWin = layero.find('iframe')[0];
                    iframeWin.contentWindow.submitHandler(index, layero);
                },
                cancel: function(index) {
                    return true;
                }
            });
        }

    </script>
</body>
</html>